package cn.com.surker.system.controller;

import cn.com.surker.spring.RestResultDto;
import cn.com.surker.system.entity.SystemConfig;
import cn.com.surker.system.service.SystemConfigService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 系统参数设置 前端控制器
 * </p>
*
* @author admin
* @since 2022-05-11
*/

@RestController
@RequestMapping("/system")
public class SystemConfigController {

    @Resource
    private SystemConfigService serviceImpl;

    /**
     *  分页查询列表
     **/
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public RestResultDto findAll(SystemConfig dto, Integer pageIndex, Integer limit){
        /**分页对象**/
        Page<SystemConfig> page = new Page<>(pageIndex, limit);

        IPage iPage = serviceImpl.findAllByPage(dto, page);
        return RestResultDto.success(iPage);
    }

    /**
     *  新增数据
     * @param dto
     **/
    @RequestMapping(value = "/save", method = RequestMethod.PUT)
    @ResponseBody
    public RestResultDto save(SystemConfig dto){

        return RestResultDto.complete(serviceImpl.saveInit(dto));
    }

    /**
     * 修改数据
     * @param dto
     * @return
     */
    @RequestMapping(value = "/update/{id}", method = RequestMethod.PUT)
    @ResponseBody
    public RestResultDto update(@PathVariable Long id, SystemConfig dto) {

        return RestResultDto.complete(serviceImpl.update(dto));
    }

    /**
     * 删除数据
     * @param id 数据主键
     * @param status 逻辑删除状态
     * @return
     */
//    @RequestMapping(value = "/delete/{id}", method = RequestMethod.PUT)
//    @ResponseBody
//    public RestResultDto update(@PathVariable Long id, Integer status) {
//
//        return serviceImpl.delete(id, status);
//    }


}



